05-07-2007, 02:34 PM
Not really a fix, and not even properly fixed anyways but good enough 
Player Warp Tiles
Especially for Advocate
At the moment, the way player movement is currently handled is, the server moves the player onto the next tile, then tells the client that the player has moved at which point the client starts moving the player. Now if the player moves onto a tile with an attribute, the server will apply that effect to the player before the client actually visually shows that the player is on the tile.
Aim of this tutorial is to change the warp tile so that it waits until the player is on the tile fully before warping them
So to begin, find this section of code in modGamelogic in the server
This piece of code basically checks if there’s a warp tile immediately after a player has moved (Remember me saying that the server applies tile attribs straight away?)
Now we need to change that so that it’ll just tell the server that the player will need to be warped soon so Change that too…
Now then, for the people who are actually reading this, you’d have noticed that I’ve used something you haven’t got so add this part to the server AccountRec type in modTypes
Also, don’t forget to change that 200 value to something more suitable for your server (depending on what speed your players walk in the client, since it depends on fps and walk/run speed)
K, add to the bottom of any module the following sub
Simple routine, checks every player, see if they need to warp, check if its actually time to warp, then after they’ve warped, reset warp tick so we don’t continuously warp them
Now for the final part, we need to call it from somewhere, this can be your choice but I’ve done it from another custom timer
I did consider using GameAi or something but that’s called every 500ms, and speeding that up could have various effects on the game (npcs on speed anyone?) So I thought the safest option would be to use a timer
I created a simple timer with interval of 25 (although you could change this, I just used it since it was ¼ of 100) and inside was the code
That is basically it, simple fix, not exactly 100% since I’m only delaying the warp and not timing it properly but it’ll do

Player Warp Tiles
Especially for Advocate

At the moment, the way player movement is currently handled is, the server moves the player onto the next tile, then tells the client that the player has moved at which point the client starts moving the player. Now if the player moves onto a tile with an attribute, the server will apply that effect to the player before the client actually visually shows that the player is on the tile.
Aim of this tutorial is to change the warp tile so that it waits until the player is on the tile fully before warping them
So to begin, find this section of code in modGamelogic in the server
Code:
' 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
This piece of code basically checks if there’s a warp tile immediately after a player has moved (Remember me saying that the server applies tile attribs straight away?)
Now we need to change that so that it’ll just tell the server that the player will need to be warped soon so Change that too…
Code:
' 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
Player(Index).WarpTick = GetTickCount + 200
Moved = YES
End If
Now then, for the people who are actually reading this, you’d have noticed that I’ve used something you haven’t got so add this part to the server AccountRec type in modTypes
Code:
WarpTick As Long
Also, don’t forget to change that 200 value to something more suitable for your server (depending on what speed your players walk in the client, since it depends on fps and walk/run speed)
K, add to the bottom of any module the following sub
Code:
Public Sub CheckWarp()
Dim i As Integer
For i = 0 To MAX_PLAYERS
If IsConnected(i) Then
If Player(i).WarpTick < GetTickCount And Player(i).WarpTick > 0 Then
Call PlayerWarp(i, Map(GetPlayerMap(i)).Tile(GetPlayerX(i), _
GetPlayerY(i)).Data1, Map(GetPlayerMap(i)).Tile(GetPlayerX(i), GetPlayerY(i)).Data2, _
Map(GetPlayerMap(i)).Tile(GetPlayerX(i), GetPlayerY(i)).Data3)
' Reset WarpTick so it doesnt constantly warp them
Player(i).WarpTick = 0
End If
End If
Next i
End Sub
Simple routine, checks every player, see if they need to warp, check if its actually time to warp, then after they’ve warped, reset warp tick so we don’t continuously warp them
Now for the final part, we need to call it from somewhere, this can be your choice but I’ve done it from another custom timer
I did consider using GameAi or something but that’s called every 500ms, and speeding that up could have various effects on the game (npcs on speed anyone?) So I thought the safest option would be to use a timer
I created a simple timer with interval of 25 (although you could change this, I just used it since it was ¼ of 100) and inside was the code
Code:
Call CheckWarp
That is basically it, simple fix, not exactly 100% since I’m only delaying the warp and not timing it properly but it’ll do
