[Guide] Movement Fix

Results 1 to 14 of 14
  1. #1
    Member LordUsagi is offline
    MemberRank
    Aug 2012 Join Date
    CanadaLocation
    69Posts

    config [Guide] Movement Fix

    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
    Spoiler:

    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 by LordUsagi; 29-08-12 at 06:14 AM.


  2. #2
    son, i am dissapoint Near is offline
    MemberRank
    Sep 2009 Join Date
    The NetherlandsLocation
    491Posts

    Re: [Guide] Movement Fix

    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.

  3. #3
    Death Welcomes All DeathLord17 is offline
    MemberRank
    Jul 2012 Join Date
    530Posts

    Re: [Guide] Movement Fix

    Not a bad fix, but as Near has stated, it's only a client fix, so your players will be teleporting about alot.

  4. #4
    Member LordUsagi is offline
    MemberRank
    Aug 2012 Join Date
    CanadaLocation
    69Posts

    Re: [Guide] Movement Fix

    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 by LordUsagi; 29-08-12 at 05:04 PM.

  5. #5
    Account Upgraded | Title Enabled! xkl is offline
    MemberRank
    Dec 2011 Join Date
    285Posts

    Re: [Guide] Movement Fix

    Sharing is caring <3

  6. #6
    Death Welcomes All DeathLord17 is offline
    MemberRank
    Jul 2012 Join Date
    530Posts

    Re: [Guide] Movement Fix

    Quote Originally Posted by xkl View Post
    Sharing is caring <3
    But what if you share something that ruins someone?

    OT: I might be able to upload some stuff for you about the fix, i've just got to root through all of my files.

  7. #7
    son, i am dissapoint Near is offline
    MemberRank
    Sep 2009 Join Date
    The NetherlandsLocation
    491Posts

    Re: [Guide] Movement Fix

    Well, movement will be improved as soon as you remove the movement queue's, so you guys might start with that.

  8. #8
    Account Upgraded | Title Enabled! xkl is offline
    MemberRank
    Dec 2011 Join Date
    285Posts

    Re: [Guide] Movement Fix

    Quote Originally Posted by DeathLord17 View Post
    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.

  9. #9
    Death Welcomes All DeathLord17 is offline
    MemberRank
    Jul 2012 Join Date
    530Posts

    Re: [Guide] Movement Fix

    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.

  10. #10
    Banned jazzy348 is offline
    BannedRank
    May 2009 Join Date
    120Posts

    Re: [Guide] Movement Fix

    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.

  11. #11
    Account Upgraded | Title Enabled! felixcruzer is offline
    MemberRank
    May 2012 Join Date
    GermanyLocation
    289Posts

    Re: [Guide] Movement Fix

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

  12. #12
    Banned jazzy348 is offline
    BannedRank
    May 2009 Join Date
    120Posts

    Re: [Guide] Movement Fix

    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.

  13. #13
    Account Upgraded | Title Enabled! felixcruzer is offline
    MemberRank
    May 2012 Join Date
    GermanyLocation
    289Posts

    Re: [Guide] Movement Fix

    Quote Originally Posted by jazzy348 View Post
    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 by felixcruzer; 15-10-12 at 03:42 PM.

  14. #14
    Banned jazzy348 is offline
    BannedRank
    May 2009 Join Date
    120Posts

    Re: [Guide] Movement Fix

    Hi,

    Thanks ever so much.



Advertisement