Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Guide] Movement Fix

Newbie Spellweaver
Joined
Aug 9, 2012
Messages
69
Reaction score
10
The major problem people seem to be complaining about with any server using PokeNet as its backbone is the movement delay. We all know it, we've all experienced and we've all seen the fix in action on certain servers. Well, I am here today to share this fix with the community of RageZone.

I'd like to give a special thanks to:
xkl
Pokemonium


Instructions
First off, you'll want to open up GameClient.java which is located in the client files of PokeNet. This is the only file we'll be editing today so no need to worry about the rest.

Now that we've got that open, look for some lines at the top similar to
Code:
	//The gui display layer
	private Display m_display;

	private WeatherService m_weather;// = new WeatherService();

Add in an extra line so that the above now looks like this

Code:
	//The gui display layer
	private Display m_display;

	//Movement Fix
	private int lastPressedKey;

	private WeatherService m_weather;// = new WeatherService();

Now, we'll search for a line that should look like
Code:
* Check if we need to loads maps

above that comment space we'll add in this code
Code:
if (lastPressedKey > -2) {
if (gc.getInput().isKeyDown(lastPressedKey))
{
handleKeyPress(lastPressedKey);
}
if ((lastPressedKey != Input.KEY_UP) && (lastPressedKey != Input.KEY_LEFT) && (lastPressedKey != Input.KEY_DOWN) && (lastPressedKey != Input.KEY_RIGHT))
{
lastPressedKey = -2;
}
}

The code above is the main fix, but to get it to all come together you'll need to make a few more edits. We'll now look for a line of code similar to..
Code:
public void keyPressed(int key, char c) {
Remove the override and the comments above it and make it look like the code below..
Code:
	public void handleKeyPress(int key) {
		lastPressedKey = key;

And finally, above that we'll place this chunk of code in

Code:
	/**
	 * Accepts the user input.
	 * @param key The integer representing the key pressed.
	 * @param c ???
	 */
	public void keyPressed(int key, char c)
	{
	lastPressedKey = key;
	}

Save your client, and compile. Run your server and your client and use the arrow keys to move around, you'll notice it's a LOT better. This fix can be applied to the other WASD movement keys as well but if you are that concerned you will be able to do that yourself.
 
Last edited:
Elite Diviner
Joined
Sep 18, 2009
Messages
414
Reaction score
149
This does fix the client side movement but not the serverside movement. You will see a lot of players out of sync etc. You can fix this by removing the serverside and clientside movement queue.
 
Newbie Spellweaver
Joined
Aug 9, 2012
Messages
69
Reaction score
10
See. This is why we share things. Because people offer constructive criticism and you learn something new. Yes this is directed at you, no I will not name you. Please learn from this.

BUT
Thanks Near and DeathLord17 for the comments and the like from Near :)
 
Last edited:
Elite Diviner
Joined
Sep 18, 2009
Messages
414
Reaction score
149
Well, movement will be improved as soon as you remove the movement queue's, so you guys might start with that.
 

xkl

Experienced Elementalist
Joined
Dec 26, 2011
Messages
284
Reaction score
116
But what if you share something that ruins someone?
Yeah I understand that. But something that will benefit the development community for PokeNet, should be shared <3 Maybe not like fully custom blown out kinda things, but you get the gist of what I'm saying. Even tho the source it's self is under a GPL license, things are not still being shared.
 
Joined
Jul 29, 2012
Messages
527
Reaction score
71
Yes, i know but the GPL license it is under has many many loopholes, you can just say that your stuff isn't ready for release because it has bugs that would cause a crash and possible damage to the machine that is using it.
 
Banned
Banned
Joined
May 6, 2009
Messages
111
Reaction score
19
Hi,

I used this fix first time and it worked great! Although I messed up my source code and stupidly did not back it up. I am now getting an error which says "The method handleKeyPress(int) is undefinded for the type GameClient"

I have followed the tutorial the same as I did last time but this time I ran into a problem.

if (lastPressedKey > -2) {
if (gc.getInput().isKeyDown(lastPressedKey))
{
handleKeyPress(lastPressedKey);
}
if ((lastPressedKey != Input.KEY_UP) && (lastPressedKey != Input.KEY_LEFT) && (lastPressedKey != Input.KEY_DOWN) && (lastPressedKey != Input.KEY_RIGHT) && (lastPressedKey != Input.KEY_W) && (lastPressedKey != Input.KEY_A) && (lastPressedKey != Input.KEY_S) && (lastPressedKey != Input.KEY_D))
{
lastPressedKey = -2;
}
}

That is the bit of code that is causing this error.

Thanks in advance,
Jazzy.
 
Experienced Elementalist
Joined
May 28, 2012
Messages
289
Reaction score
51
Undo your Movement fix changes, do it again and do it exactly as in the tutorial above..if the error appears again you should delete your workspace and reimport the client into eclipse

Or you use Pokemon Nexus, the movement is already fixed in this source ;)
PKMN-NEXUS

At last i want to give you a tip:
Don't usw the pokenet source, wait for nears recode or use the Pokemon Dawn Source, the PokeMMO Source or the PKMN-NEXUS Source, it wont further bring you..
 
Banned
Banned
Joined
May 6, 2009
Messages
111
Reaction score
19
Hi,

Thanks for the reply shortly after asking for help it managed to fix itself. Also thanks for the tip on what sources to use. Do any of these have animated Pokemon/battles? Of Pokemon that follows the player? The players of my Pokemon MMO have requested that I add them many times but my java knowledge isn't enough to know how to do it.
 
Experienced Elementalist
Joined
May 28, 2012
Messages
289
Reaction score
51
Hi,

Thanks for the reply shortly after asking for help it managed to fix itself. Also thanks for the tip on what sources to use. Do any of these have animated Pokemon/battles? Of Pokemon that follows the player? The players of my Pokemon MMO have requested that I add them many times but my java knowledge isn't enough to know how to do it.

PokeMMO (its in the Release section) has pokemon following the player and a bit animated battles ;)
 
Last edited:
Back
Top