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

8 Directional Movement


blkcrow
 Share

Recommended Posts

Client Side

Hi this is the first tutorial that i am releasing on this forum. This system has been tested and made in EO 2.3

First go to modGlobals and find

```
Public DirRight as boolean
```

Add below it

```

Public DirUpLeft As Boolean

Public DirUpRight As Boolean

Public DirDownLeft As Boolean

Public DirDownRight As Boolean

```

In modInput in the CheckKeys sub find

```

If GetAsyncKeyState(VK_UP) >= 0 Then DirUp = False

```

And add above it

```

If GetAsyncKeyState(VK_UP) >= 0 And GetAsyncKeyState(VK_LEFT) >= 0 Then DirUpLeft = False

If GetAsyncKeyState(VK_UP) >= 0 And GetAsyncKeyState(VK_RIGHT) >= 0 Then DirUpRight = False

If GetAsyncKeyState(VK_DOWN) >= 0 And GetAsyncKeyState(VK_LEFT) >= 0 Then DirDownLeft = False

If GetAsyncKeyState(VK_DOWN) >= 0 And GetAsyncKeyState(VK_RIGHT) >= 0 Then DirDownRight = False

```

In the same module replace the CheckInputKeys sub with this one

```

Public Sub CheckInputKeys()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If GetKeyState(vbKeyShift) < 0 Then

ShiftDown = True

Else

ShiftDown = False

End If

If GetKeyState(vbKeyReturn) < 0 Then

CheckMapGetItem

End If

If GetKeyState(vbKeyControl) < 0 Then

ControlDown = True

Else

ControlDown = False

End If

'Move Up Left

If GetAsyncKeyState(VK_UP) < 0 And GetAsyncKeyState(VK_LEFT) < 0 Then

DirUp = False

DirDown = False

DirLeft = False

DirRight = False

DirUpLeft = True

DirUpRight = False

DirDownLeft = False

DirDownRight = False

Exit Sub

Else

DirUpLeft = False

End If

'Move Up Right

If GetAsyncKeyState(VK_UP) < 0 And GetAsyncKeyState(VK_RIGHT) < 0 Then

DirUp = False

DirDown = False

DirLeft = False

DirRight = False

DirUpLeft = False

DirUpRight = True

DirDownLeft = False

DirDownRight = False

Exit Sub

Else

DirUpRight = False

End If

'Move Down Left

If GetAsyncKeyState(VK_DOWN) < 0 And GetAsyncKeyState(VK_LEFT) < 0 Then

DirUp = False

DirDown = False

DirLeft = False

DirRight = False

DirUpLeft = False

DirUpRight = False

DirDownLeft = True

DirDownRight = False

Exit Sub

Else

DirDownLeft = False

End If

'Move Down Right

If GetAsyncKeyState(VK_DOWN) < 0 And GetAsyncKeyState(VK_RIGHT) < 0 Then

DirUp = False

DirDown = False

DirLeft = False

DirRight = False

DirUpLeft = False

DirUpRight = False

DirDownLeft = False

DirDownRight = True

Exit Sub

Else

DirDownRight = False

End If

'Move Up

If GetAsyncKeyState(VK_UP) < 0 Then

DirUp = True

DirDown = False

DirLeft = False

DirRight = False

DirUpLeft = False

DirUpRight = False

DirDownLeft = False

DirDownRight = False

Exit Sub

Else

DirUp = False

End If

'Move Right

If GetAsyncKeyState(VK_RIGHT) < 0 Then

DirUp = False

DirDown = False

DirLeft = False

DirRight = True

DirUpLeft = False

DirUpRight = False

DirDownLeft = False

DirDownRight = False

Exit Sub

Else

DirRight = False

End If

'Move down

If GetAsyncKeyState(VK_DOWN) < 0 Then

DirUp = False

DirDown = True

DirLeft = False

DirRight = False

DirUpLeft = False

DirUpRight = False

DirDownLeft = False

DirDownRight = False

Exit Sub

Else

DirDown = False

End If

'Move left

If GetAsyncKeyState(VK_LEFT) < 0 Then

DirUp = False

DirDown = False

DirLeft = True

DirRight = False

DirUpLeft = False

DirUpRight = False

DirDownLeft = False

DirDownRight = False

Exit Sub

Else

DirLeft = False

End If

' Error handler

Exit Sub

errorhandler:

HandleError "CheckInputKeys", "modInput", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

Now in modConstants find

```
Public Const DIR_RIGHT As Byte = 3
```

And add directly below it

```

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

```

In modGameLogic in sub CanMove find

```

d = GetPlayerDir(MyIndex)

```

And add below it

```

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) 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 And Map.Left > 0 Then

Call MapEditorLeaveMap

Call SendPlayerRequestNewMap

GettingMap = True

CanMoveNow = False

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.MaxX Then

If CheckDirection(DIR_UP) 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 And Map.Right > 0 Then

Call MapEditorLeaveMap

Call SendPlayerRequestNewMap

GettingMap = True

CanMoveNow = False

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) < Map.MaxY And GetPlayerX(MyIndex) > 0 Then

If CheckDirection(DIR_DOWN) 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 And Map.Left > 0 Then

Call MapEditorLeaveMap

Call SendPlayerRequestNewMap

GettingMap = True

CanMoveNow = False

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) < Map.MaxY And GetPlayerX(MyIndex) < Map.MaxX Then

If CheckDirection(DIR_DOWN) 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 And Map.Right > 0 Then

Call MapEditorLeaveMap

Call SendPlayerRequestNewMap

GettingMap = True

CanMoveNow = False

End If

CanMove = False

Exit Function

End If

End If

```

In the same module but in function CheckDirection find

```

Case DIR_RIGHT

x = GetPlayerX(MyIndex) + 1

y = GetPlayerY(MyIndex)

```

Add two new cases below it

```

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

```

in sub CheckMovement find

```

Case DIR_RIGHT

Call SendPlayerMove

Player(MyIndex).XOffset = PIC_X * -1

Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)

```

Add below it

```

Case DIR_UP_LEFT

Call SendPlayerMove

Player(MyIndex).YOffset = PIC_Y

Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)

Player(MyIndex).XOffset = PIC_X

Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)

Case DIR_UP_RIGHT

Call SendPlayerMove

Player(MyIndex).YOffset = PIC_Y

Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)

Player(MyIndex).XOffset = PIC_X * -1

Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)

Case DIR_DOWN_LEFT

Call SendPlayerMove

Player(MyIndex).YOffset = PIC_Y * -1

Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)

Player(MyIndex).XOffset = PIC_X

Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)

Case DIR_DOWN_RIGHT

Call SendPlayerMove

Player(MyIndex).YOffset = PIC_Y * -1

Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)

Player(MyIndex).XOffset = PIC_X * -1

Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)

```

Now in modHandleData in the sub HandlePlayerMove find

```

Case DIR_RIGHT

Player(i).XOffset = PIC_X * -1

```

Add directly below it

```

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

```

In modGameLogic in sub ProcessMovement find

```

Case DIR_RIGHT

Player(Index).XOffset = Player(Index).XOffset + MovementSpeed

If Player(Index).XOffset > 0 Then Player(Index).XOffset = 0

```

And add below it

```

Case DIR_UP_LEFT

Player(Index).YOffset = Player(Index).YOffset - MovementSpeed

If Player(Index).YOffset < 0 Then Player(Index).YOffset = 0

Player(Index).XOffset = Player(Index).XOffset - MovementSpeed

If Player(Index).XOffset < 0 Then Player(Index).XOffset = 0

Case DIR_UP_RIGHT

Player(Index).YOffset = Player(Index).YOffset - MovementSpeed

If Player(Index).YOffset < 0 Then Player(Index).YOffset = 0

Player(Index).XOffset = Player(Index).XOffset + MovementSpeed

If Player(Index).XOffset > 0 Then Player(Index).XOffset = 0

Case DIR_DOWN_LEFT

Player(Index).YOffset = Player(Index).YOffset + MovementSpeed

If Player(Index).YOffset > 0 Then Player(Index).YOffset = 0

Player(Index).XOffset = Player(Index).XOffset - MovementSpeed

If Player(Index).XOffset < 0 Then Player(Index).XOffset = 0

Case DIR_DOWN_RIGHT

Player(Index).YOffset = Player(Index).YOffset + MovementSpeed

If Player(Index).YOffset > 0 Then Player(Index).YOffset = 0

Player(Index).XOffset = Player(Index).XOffset + MovementSpeed

If Player(Index).XOffset > 0 Then Player(Index).XOffset = 0

```

in the same sub find

```

If GetPlayerDir(Index) = DIR_RIGHT Or GetPlayerDir(Index) = DIR_DOWN Then

```

And replace it with this

```

If GetPlayerDir(Index) = DIR_RIGHT Or GetPlayerDir(Index) = DIR_DOWN Or GetPlayerDir(Index) = DIR_DOWN_LEFT Or GetPlayerDir(Index) = DIR_DOWN_RIGHT Then

```

Exactly below this sub in sub ProcessNpcMovement find

```

Case DIR_RIGHT

MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).XOffset > 0 Then MapNpc(MapNpcNum).XOffset = 0

```

Add below it

```

Case DIR_UP_LEFT

MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).YOffset < 0 Then MapNpc(MapNpcNum).YOffset = 0

MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).XOffset < 0 Then MapNpc(MapNpcNum).XOffset = 0

Case DIR_UP_RIGHT

MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).YOffset < 0 Then MapNpc(MapNpcNum).YOffset = 0

MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).XOffset > 0 Then MapNpc(MapNpcNum).XOffset = 0

Case DIR_DOWN_LEFT

MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).YOffset > 0 Then MapNpc(MapNpcNum).YOffset = 0

MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).XOffset < 0 Then MapNpc(MapNpcNum).XOffset = 0

Case DIR_DOWN_RIGHT

MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).YOffset > 0 Then MapNpc(MapNpcNum).YOffset = 0

MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

If MapNpc(MapNpcNum).XOffset > 0 Then MapNpc(MapNpcNum).XOffset = 0

```

In modDirectDraw7 under the sub BltPlayer find

```

Case DIR_LEFT

spritetop = 1

```

And add below it

```

Case DIR_UP_LEFT

spritetop = 3

Case DIR_UP_RIGHT

spritetop = 3

Case DIR_DOWN_LEFT

spritetop = 0

Case DIR_DOWN_RIGHT

spritetop = 0

```

in the same sub find

```

Case DIR_RIGHT

If (Player(Index).XOffset < -8) Then anim = Player(Index).Step

```

And add below it

```

Case DIR_UP_LEFT

If (Player(Index).YOffset > 8) And (Player(Index).XOffset > 8) Then anim = Player(Index).Step

Case DIR_UP_RIGHT

If (Player(Index).YOffset > 8) And (Player(Index).XOffset < -8) Then anim = Player(Index).Step

Case DIR_DOWN_LEFT

If (Player(Index).YOffset < -8) And (Player(Index).XOffset > 8) Then anim = Player(Index).Step

Case DIR_DOWN_RIGHT

If (Player(Index).YOffset < -8) And (Player(Index).XOffset < -8) Then anim = Player(Index).Step

```

In sub BltNpc find

```

Case DIR_RIGHT

If (MapNpc(MapNpcNum).XOffset < -8) Then anim = MapNpc(MapNpcNum).Step

```

Add below it

```

Case DIR_UP_LEFT

If (MapNpc(MapNpcNum).YOffset > 8) And (MapNpc(MapNpcNum).XOffset > 8) Then anim = MapNpc(MapNpcNum).Step

Case DIR_UP_RIGHT

If (MapNpc(MapNpcNum).YOffset > 8) And (MapNpc(MapNpcNum).XOffset < -8) Then anim = MapNpc(MapNpcNum).Step

Case DIR_DOWN_LEFT

If (MapNpc(MapNpcNum).YOffset < -8) And (MapNpc(MapNpcNum).XOffset > 8) Then anim = MapNpc(MapNpcNum).Step

Case DIR_DOWN_RIGHT

If (MapNpc(MapNpcNum).YOffset < -8) And (MapNpc(MapNpcNum).XOffset < -8) Then anim = MapNpc(MapNpcNum).Step

```

in the same mod find

Add below it

```

Case DIR_UP_LEFT

spritetop = 3

Case DIR_UP_RIGHT

spritetop = 3

Case DIR_DOWN_LEFT

spritetop = 0

Case DIR_DOWN_RIGHT

spritetop = 0

```

On modGameLogic in function IsTryingToMove find

```

If DirUp Or DirDown Or DirLeft Or DirRight Then

```

And replace it with

```

If DirUp Or DirDown Or DirLeft Or DirRight Or DirUpLeft Or DirUpRight Or DirDownLeft Or DirDownRight Then

```

In modHandleData in sub HandlePlayerData find

```

DirRight = False

```

Add below it

```

DirUpLeft = False

DirUpRight = False

DirDownLeft = False

DirDownRight = False

```

And we are done in the client ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

Server Side

In modConstants find

```

Public Const DIR_RIGHT As Byte = 3

```

Add below it

```

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

```

in modGameLogic in sub CanNpcMove find

```

If mapnum <= 0 Or mapnum > MAX_MAPS Or mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or Dir < DIR_UP Or Dir > DIR_RIGHT Then

```

Replace it with

```

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

```

in the same sub find

```

Select Case Dir

```

and add below it

```

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 And n <> TILE_TYPE_NPCSPAWN Then

CanNpcMove = False

Exit Function

End If

' Check to make sure that there is not a player in the way

For i = 1 To Player_HighIndex

If IsPlaying(i) Then

If (GetPlayerMap(i) = mapnum) And (GetPlayerX(i) = MapNpc(mapnum).Npc(mapNpcNum).x - 1) And (GetPlayerY(i) = MapNpc(mapnum).Npc(mapNpcNum).y - 1) Then

CanNpcMove = False

Exit Function

End If

End If

Next

' 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).Npc(i).Num > 0) And (MapNpc(mapnum).Npc(i).x = MapNpc(mapnum).Npc(mapNpcNum).x - 1) And (MapNpc(mapnum).Npc(i).y = MapNpc(mapnum).Npc(mapNpcNum).y - 1) Then

CanNpcMove = False

Exit Function

End If

Next

' Directional blocking

If isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_UP + 1) And isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_LEFT + 1) Then

CanNpcMove = False

Exit Function

End If

Else

CanNpcMove = False

End If

Case DIR_UP_RIGHT

' Check to make sure not outside of boundries

If y > 0 And x < Map(mapnum).MaxX 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 And n <> TILE_TYPE_NPCSPAWN Then

CanNpcMove = False

Exit Function

End If

' Check to make sure that there is not a player in the way

For i = 1 To Player_HighIndex

If IsPlaying(i) Then

If (GetPlayerMap(i) = mapnum) And (GetPlayerX(i) = MapNpc(mapnum).Npc(mapNpcNum).x + 1) And (GetPlayerY(i) = MapNpc(mapnum).Npc(mapNpcNum).y - 1) Then

CanNpcMove = False

Exit Function

End If

End If

Next

' 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).Npc(i).Num > 0) And (MapNpc(mapnum).Npc(i).x = MapNpc(mapnum).Npc(mapNpcNum).x + 1) And (MapNpc(mapnum).Npc(i).y = MapNpc(mapnum).Npc(mapNpcNum).y - 1) Then

CanNpcMove = False

Exit Function

End If

Next

' Directional blocking

If isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_UP + 1) And isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_RIGHT + 1) Then

CanNpcMove = False

Exit Function

End If

Else

CanNpcMove = False

End If

Case DIR_DOWN_LEFT

' Check to make sure not outside of boundries

If y < Map(mapnum).MaxY 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 And n <> TILE_TYPE_NPCSPAWN Then

CanNpcMove = False

Exit Function

End If

' Check to make sure that there is not a player in the way

For i = 1 To Player_HighIndex

If IsPlaying(i) Then

If (GetPlayerMap(i) = mapnum) And (GetPlayerX(i) = MapNpc(mapnum).Npc(mapNpcNum).x - 1) And (GetPlayerY(i) = MapNpc(mapnum).Npc(mapNpcNum).y + 1) Then

CanNpcMove = False

Exit Function

End If

End If

Next

' 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).Npc(i).Num > 0) And (MapNpc(mapnum).Npc(i).x = MapNpc(mapnum).Npc(mapNpcNum).x - 1) And (MapNpc(mapnum).Npc(i).y = MapNpc(mapnum).Npc(mapNpcNum).y + 1) Then

CanNpcMove = False

Exit Function

End If

Next

' Directional blocking

If isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_DOWN + 1) And isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_LEFT + 1) Then

CanNpcMove = False

Exit Function

End If

Else

CanNpcMove = False

End If

Case DIR_DOWN_RIGHT

' Check to make sure not outside of boundries

If y < Map(mapnum).MaxY And x < Map(mapnum).MaxX 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 And n <> TILE_TYPE_NPCSPAWN Then

CanNpcMove = False

Exit Function

End If

' Check to make sure that there is not a player in the way

For i = 1 To Player_HighIndex

If IsPlaying(i) Then

If (GetPlayerMap(i) = mapnum) And (GetPlayerX(i) = MapNpc(mapnum).Npc(mapNpcNum).x + 1) And (GetPlayerY(i) = MapNpc(mapnum).Npc(mapNpcNum).y + 1) Then

CanNpcMove = False

Exit Function

End If

End If

Next

' 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).Npc(i).Num > 0) And (MapNpc(mapnum).Npc(i).x = MapNpc(mapnum).Npc(mapNpcNum).x + 1) And (MapNpc(mapnum).Npc(i).y = MapNpc(mapnum).Npc(mapNpcNum).y + 1) Then

CanNpcMove = False

Exit Function

End If

Next

' Directional blocking

If isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_DOWN + 1) And isDirBlocked(Map(mapnum).Tile(MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y).DirBlock, DIR_RIGHT + 1) Then

CanNpcMove = False

Exit Function

End If

Else

CanNpcMove = False

End If

```

in the same module in sub NpcMove find

```

If mapnum <= 0 Or mapnum > MAX_MAPS Or mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or Dir < DIR_UP Or Dir > DIR_RIGHT Or movement < 1 Or movement > 2 Then

```

and replace it with

```

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

```

In the same sub find

```

Select Case Dir

```

add below it

```

Case DIR_UP_LEFT

MapNpc(mapnum).Npc(mapNpcNum).y = MapNpc(mapnum).Npc(mapNpcNum).y - 1

MapNpc(mapnum).Npc(mapNpcNum).x = MapNpc(mapnum).Npc(mapNpcNum).x - 1

Set buffer = New clsBuffer

buffer.WriteLong SNpcMove

buffer.WriteLong mapNpcNum

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).x

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).y

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).Dir

buffer.WriteLong movement

SendDataToMap mapnum, buffer.ToArray()

Set buffer = Nothing

Case DIR_UP_RIGHT

MapNpc(mapnum).Npc(mapNpcNum).y = MapNpc(mapnum).Npc(mapNpcNum).y - 1

MapNpc(mapnum).Npc(mapNpcNum).x = MapNpc(mapnum).Npc(mapNpcNum).x + 1

Set buffer = New clsBuffer

buffer.WriteLong SNpcMove

buffer.WriteLong mapNpcNum

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).x

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).y

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).Dir

buffer.WriteLong movement

SendDataToMap mapnum, buffer.ToArray()

Set buffer = Nothing

Case DIR_DOWN_LEFT

MapNpc(mapnum).Npc(mapNpcNum).y = MapNpc(mapnum).Npc(mapNpcNum).y + 1

MapNpc(mapnum).Npc(mapNpcNum).x = MapNpc(mapnum).Npc(mapNpcNum).x - 1

Set buffer = New clsBuffer

buffer.WriteLong SNpcMove

buffer.WriteLong mapNpcNum

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).x

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).y

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).Dir

buffer.WriteLong movement

SendDataToMap mapnum, buffer.ToArray()

Set buffer = Nothing

Case DIR_DOWN_RIGHT

MapNpc(mapnum).Npc(mapNpcNum).y = MapNpc(mapnum).Npc(mapNpcNum).y + 1

MapNpc(mapnum).Npc(mapNpcNum).x = MapNpc(mapnum).Npc(mapNpcNum).x + 1

Set buffer = New clsBuffer

buffer.WriteLong SNpcMove

buffer.WriteLong mapNpcNum

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).x

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).y

buffer.WriteLong MapNpc(mapnum).Npc(mapNpcNum).Dir

buffer.WriteLong movement

SendDataToMap mapnum, buffer.ToArray()

Set buffer = Nothing

```

in modHandleData in sub HandlePlayerMove find

```

If Dir < DIR_UP Or Dir > DIR_RIGHT Then

```

and replace it with

```

If Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then

```

in the same module in sub HandlePlayerDir find

```

If Dir < DIR_UP Or Dir > DIR_RIGHT Then

```

and replace it with

```

If Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then

```

in sub HandleRequestNewMap find

```

If Dir < DIR_UP Or Dir > DIR_RIGHT Then

```

and replace it with

```

If Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then

```

in modServerLoop in sub UpdateMapLogic find

```

Select Case i

Case 0

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

Case 1

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

Case 2

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

Case 3

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

End Select

```

and replace it with this

```

Select Case i

Case 0

' Up Left

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_LEFT) Then

Call NpcMove(mapnum, x, DIR_UP_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Up right

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_RIGHT) Then

Call NpcMove(mapnum, x, DIR_UP_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Left

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_LEFT) Then

Call NpcMove(mapnum, x, DIR_DOWN_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Right

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_RIGHT) Then

Call NpcMove(mapnum, x, DIR_DOWN_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

Case 1

' Up Left

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_LEFT) Then

Call NpcMove(mapnum, x, DIR_UP_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Up right

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_RIGHT) Then

Call NpcMove(mapnum, x, DIR_UP_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Left

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_LEFT) Then

Call NpcMove(mapnum, x, DIR_DOWN_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Right

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_RIGHT) Then

Call NpcMove(mapnum, x, DIR_DOWN_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

Case 2

' Up Left

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_LEFT) Then

Call NpcMove(mapnum, x, DIR_UP_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Up right

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_RIGHT) Then

Call NpcMove(mapnum, x, DIR_UP_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Left

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_LEFT) Then

Call NpcMove(mapnum, x, DIR_DOWN_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Right

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_RIGHT) Then

Call NpcMove(mapnum, x, DIR_DOWN_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

Case 3

' Up Left

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_LEFT) Then

Call NpcMove(mapnum, x, DIR_UP_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Up right

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_UP_RIGHT) Then

Call NpcMove(mapnum, x, DIR_UP_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Left

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x > TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_LEFT) Then

Call NpcMove(mapnum, x, DIR_DOWN_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Down Right

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If MapNpc(mapnum).Npc(x).x < TargetX Then

If CanNpcMove(mapnum, x, DIR_DOWN_RIGHT) Then

Call NpcMove(mapnum, x, DIR_DOWN_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

End If

' Left

If MapNpc(mapnum).Npc(x).x > TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_LEFT) Then

Call NpcMove(mapnum, x, DIR_LEFT, MOVING_WALKING)

didwalk = True

End If

End If

' Right

If MapNpc(mapnum).Npc(x).x < TargetX And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_RIGHT) Then

Call NpcMove(mapnum, x, DIR_RIGHT, MOVING_WALKING)

didwalk = True

End If

End If

' Up

If MapNpc(mapnum).Npc(x).y > TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_UP) Then

Call NpcMove(mapnum, x, DIR_UP, MOVING_WALKING)

didwalk = True

End If

End If

' Down

If MapNpc(mapnum).Npc(x).y < TargetY And Not didwalk Then

If CanNpcMove(mapnum, x, DIR_DOWN) Then

Call NpcMove(mapnum, x, DIR_DOWN, MOVING_WALKING)

didwalk = True

End If

End If

End Select

```

in modPlayer in sub PlayerMove find

```

If IsPlaying(index) = False Or Dir < DIR_UP Or Dir > DIR_RIGHT Or movement < 1 Or movement > 2 Then

```

replace it with

```

If IsPlaying(index) = False Or Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Or movement < 1 Or movement > 2 Then

```

in the same sub find

```

Select Case Dir

```

below it add

```

Case DIR_UP_LEFT

' Check to make sure not outside of boundries

If GetPlayerY(index) > 0 Or GetPlayerX(index) > 0 Then

' Check to make sure that the tile is walkable

If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_UP + 1) And Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_LEFT + 1) Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index) - 1).Type <> TILE_TYPE_RESOURCE 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 SetPlayerY(index, GetPlayerY(index) - 1)

Call SetPlayerX(index, GetPlayerX(index) - 1)

SendPlayerMove index, movement, sendToSelf

Moved = YES

End If

End If

End If

End If

Else

' Check to see if we can move them to the another map

If Map(GetPlayerMap(index)).Up > 0 And Map(GetPlayerMap(index)).Left > 0 Then

NewMapY = Map(Map(GetPlayerMap(index)).Up).MaxY

Call PlayerWarp(index, Map(GetPlayerMap(index)).Up, GetPlayerX(index), NewMapY)

Moved = YES

' clear their target

TempPlayer(index).target = 0

TempPlayer(index).targetType = TARGET_TYPE_NONE

SendTarget index

End If

End If

Case DIR_UP_RIGHT

' Check to make sure not outside of boundries

If GetPlayerY(index) > 0 Or GetPlayerX(index) < Map(mapnum).MaxX Then

' Check to make sure that the tile is walkable

If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_UP + 1) And Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_RIGHT + 1) Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index) - 1).Type <> TILE_TYPE_RESOURCE 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 SetPlayerY(index, GetPlayerY(index) - 1)

Call SetPlayerX(index, GetPlayerX(index) + 1)

SendPlayerMove index, movement, sendToSelf

Moved = YES

End If

End If

End If

End If

Else

' Check to see if we can move them to the another map

If Map(GetPlayerMap(index)).Up > 0 And Map(GetPlayerMap(index)).Right > 0 Then

NewMapY = Map(Map(GetPlayerMap(index)).Up).MaxY

Call PlayerWarp(index, Map(GetPlayerMap(index)).Up, GetPlayerX(index), NewMapY)

Moved = YES

' clear their target

TempPlayer(index).target = 0

TempPlayer(index).targetType = TARGET_TYPE_NONE

SendTarget index

End If

End If

Case DIR_DOWN_LEFT

' Check to make sure not outside of boundries

If GetPlayerY(index) < Map(mapnum).MaxY Or GetPlayerX(index) > 0 Then

' Check to make sure that the tile is walkable

If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_DOWN + 1) And Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_LEFT + 1) Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index) + 1).Type <> TILE_TYPE_BLOCKED Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index) + 1).Type <> TILE_TYPE_RESOURCE 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 SetPlayerY(index, GetPlayerY(index) + 1)

Call SetPlayerX(index, GetPlayerX(index) - 1)

SendPlayerMove index, movement, sendToSelf

Moved = YES

End If

End If

End If

End If

Else

' Check to see if we can move them to the another map

If Map(GetPlayerMap(index)).Down > 0 And Map(GetPlayerMap(index)).Left > 0 Then

Call PlayerWarp(index, Map(GetPlayerMap(index)).Down, GetPlayerX(index), 0)

Moved = YES

' clear their target

TempPlayer(index).target = 0

TempPlayer(index).targetType = TARGET_TYPE_NONE

SendTarget index

End If

End If

Case DIR_DOWN_RIGHT

' Check to make sure not outside of boundries

If GetPlayerY(index) < Map(mapnum).MaxY Or GetPlayerX(index) < Map(mapnum).MaxX Then

' Check to make sure that the tile is walkable

If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_DOWN + 1) And Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_RIGHT + 1) Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index) + 1).Type <> TILE_TYPE_BLOCKED Then

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index) + 1).Type <> TILE_TYPE_RESOURCE 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 SetPlayerY(index, GetPlayerY(index) + 1)

Call SetPlayerX(index, GetPlayerX(index) + 1)

SendPlayerMove index, movement, sendToSelf

Moved = YES

End If

End If

End If

End If

Else

' Check to see if we can move them to the another map

If Map(GetPlayerMap(index)).Down > 0 And Map(GetPlayerMap(index)).Right > 0 Then

Call PlayerWarp(index, Map(GetPlayerMap(index)).Down, GetPlayerX(index), 0)

Moved = YES

' clear their target

TempPlayer(index).target = 0

TempPlayer(index).targetType = TARGET_TYPE_NONE

SendTarget index

End If

End If

```

in sub ForcePlayerMove replace the whole sub with this

```

Sub ForcePlayerMove(ByVal index As Long, ByVal movement As Long, ByVal Direction As Long)

If Direction < DIR_UP Or Direction > DIR_DOWN_RIGHT Then Exit Sub

If movement < 1 Or movement > 2 Then Exit Sub

Select Case Direction

Case DIR_UP

If GetPlayerY(index) = 0 Then Exit Sub

Case DIR_LEFT

If GetPlayerX(index) = 0 Then Exit Sub

Case DIR_DOWN

If GetPlayerY(index) = Map(GetPlayerMap(index)).MaxY Then Exit Sub

Case DIR_RIGHT

If GetPlayerX(index) = Map(GetPlayerMap(index)).MaxX Then Exit Sub

Case DIR_UP_LEFT

If GetPlayerY(index) = 0 And GetPlayerX(index) = 0 Then Exit Sub

Case DIR_UP_RIGHT

If GetPlayerY(index) = 0 And GetPlayerX(index) = Map(GetPlayerMap(index)).MaxX Then Exit Sub

Case DIR_DOWN_LEFT

If GetPlayerY(index) = Map(GetPlayerMap(index)).MaxY And GetPlayerX(index) = 0 Then Exit Sub

Case DIR_DOWN_RIGHT

If GetPlayerY(index) = Map(GetPlayerMap(index)).MaxY And GetPlayerX(index) = Map(GetPlayerMap(index)).MaxX Then Exit Sub

End Select

PlayerMove index, Direction, movement, True

End Sub

```

in sub UseItem find

```

Case DIR_RIGHT

If GetPlayerX(index) < Map(GetPlayerMap(index)).MaxX Then

x = GetPlayerX(index) + 1

y = GetPlayerY(index)

Else

Exit Sub

End If

```

add below it

```

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) < Map(GetPlayerMap(index)).MaxX Then

x = GetPlayerX(index) + 1

y = GetPlayerY(index) - 1

Else

Exit Sub

End If

Case DIR_DOWN_LEFT

If GetPlayerY(index) < Map(GetPlayerMap(index)).MaxY 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) < Map(GetPlayerMap(index)).MaxY And GetPlayerX(index) > 0 Then

x = GetPlayerX(index) + 1

y = GetPlayerY(index) + 1

Else

Exit Sub

End If

```

in modCombat in sub CanPlayerAttackNpc find

```

Select Case GetPlayerDir(attacker)

Case DIR_UP

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y + 1

Case DIR_DOWN

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y - 1

Case DIR_LEFT

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x + 1

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y

Case DIR_RIGHT

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x - 1

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y

End Select

```

and replace it with

```

Select Case GetPlayerDir(attacker)

Case DIR_UP, DIR_UP_LEFT, DIR_UP_RIGHT

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y + 1

Case DIR_DOWN, DIR_DOWN_LEFT, DIR_DOWN_RIGHT

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y - 1

Case DIR_LEFT

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x + 1

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y

Case DIR_RIGHT

NpcX = MapNpc(mapnum).Npc(mapNpcNum).x - 1

NpcY = MapNpc(mapnum).Npc(mapNpcNum).y

End Select

```

in the sub CanPlayerAttackPlayer find

```

Select Case GetPlayerDir(attacker)

Case DIR_UP

If Not ((GetPlayerY(victim) + 1 = GetPlayerY(attacker)) And (GetPlayerX(victim) = GetPlayerX(attacker))) Then Exit Function

Case DIR_DOWN

If Not ((GetPlayerY(victim) - 1 = GetPlayerY(attacker)) And (GetPlayerX(victim) = GetPlayerX(attacker))) Then Exit Function

Case DIR_LEFT

If Not ((GetPlayerY(victim) = GetPlayerY(attacker)) And (GetPlayerX(victim) + 1 = GetPlayerX(attacker))) Then Exit Function

Case DIR_RIGHT

If Not ((GetPlayerY(victim) = GetPlayerY(attacker)) And (GetPlayerX(victim) - 1 = GetPlayerX(attacker))) Then Exit Function

Case Else

Exit Function

End Select

```

and replace it with

```

Select Case GetPlayerDir(attacker)

Case DIR_UP, DIR_UP_LEFT, DIR_UP_RIGHT

If Not ((GetPlayerY(victim) + 1 = GetPlayerY(attacker)) And (GetPlayerX(victim) = GetPlayerX(attacker))) Then Exit Function

Case DIR_DOWN, DIR_DOWN_LEFT, DIR_DOWN_RIGHT

If Not ((GetPlayerY(victim) - 1 = GetPlayerY(attacker)) And (GetPlayerX(victim) = GetPlayerX(attacker))) Then Exit Function

Case DIR_LEFT

If Not ((GetPlayerY(victim) = GetPlayerY(attacker)) And (GetPlayerX(victim) + 1 = GetPlayerX(attacker))) Then Exit Function

Case DIR_RIGHT

If Not ((GetPlayerY(victim) = GetPlayerY(attacker)) And (GetPlayerX(victim) - 1 = GetPlayerX(attacker))) Then Exit Function

Case Else

Exit Function

End Select

```

Thats it! I thought it was never gonna end ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)
Link to comment
Share on other sites

Here I had a problem with the npcs. The npcs walk "blinking" when going diagonally.

The rest seems to work without problems.

Thanks, and if the solution to npcs, ask to speak what is. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> Question about the code, say I added ranged projectiles or linear spells, would I need to change anything to make this work? Any difference in how it targets?

No this code does not touch targeting i dont know though what changes your systems make to the code so i cant be sure but i dont think you will have a problem

> Here I had a problem with the npcs. The npcs walk "blinking" when going diagonally.
>
> The rest seems to work without problems.
>
> Thanks, and if the solution to npcs, ask to speak what is. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

I had completly forgoten about the NPC movement and remembered it before i posted the tutorial so it was something like a last minute edit i will look at it again and try to fix it when i get the time
Link to comment
Share on other sites

> Thank you ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

You are welcome

> This is a great release, I was thinking of this as a possibility for the up coming programming contest since it hasn't been reportedly released until now, great job here. This will most definitely be useful or just fun for many games.

Programming contest!? ![:blink:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/blink.png) When? i hope it will be some time before it begins i in the process of moving and i cant code much
Link to comment
Share on other sites

> I had in included this feature in one of my EO edit releases over a year ago…not sure if you did this from scratch or learnt from mine but either way good on ya for releasing this for everyone as a tutorial, I know players will love it!

Thanks. I have made it from scratch. I remember your EO edit the one with the WASD and mouse movement right? ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png) I remember it i never downloaded though
Link to comment
Share on other sites

  • 4 months later...
  • 4 months later...

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...