1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, If you'd like to instant message with many other users, then join our
    Official Rune-Status Discord Server!
    Dismiss Notice
  3. Got your own Server? Looking for a Server to play right now??
    Make sure you check out the Public Server Directory!
    Dismiss Notice
  4. If you're new to the Rsps Scene and want to jump straight into learning how to Set-up and Customise your own RuneScape Private Sever then check out the Guides and Tutorials for RS2 here.
    Dismiss Notice
Dismiss Notice
Hey Guest,
Are you sure your posting in the Right Sections?
If your unsure which RuneTek version you are working with visit this page to find out.

768+ (RS3) NXT to login screen

Discussion in 'Guides & Tutorials' started by Techdaan, Jan 16, 2019.

  1. NXT Client Tutorial

    First of all, this is going to be a technical post. Explaining everything in depth would require an immense amount of time which I do not have. I would like to thank and credit Bart (Velocity) for his NXT dump, it's a very useful source of information on NXT. I would also like to thank Brad/JTlrFrost for introducing me to RSPS development and explaining me to rev a private server around half a year ago.

    If anything is wrong with this tutorial or the resources I provided (Patcher, Apache webhost files) please let me know and I'll fix it as soon as possible.

    The reason I've written this tutorials is because I've noticed a lot of people are working on NXT. To save everyone's time I'll be sharing my finds in regards to NXT, besides, the RS3 scene seems to be on a near-standstill and I'd love to see some progression going on.

    In this tutorial I will be explaining how to get NXT to launch as well getting your JS5 server ready to support NXT. I will not be offering tools to find packets, this is something for the rest of the community to figure out, unless I feel generous in the future and decide to release some tools.

    Downloading the client and launcher
    The client for Windows x64 can be downloaded from the RuneScape website. First download the config: RuneScape NXT Windows x64 game configuration
    Once you've downloaded the configuration you can download the client by visiting: "[CODEBASE]/client?binaryType=2&crc=[CRC]&fileName=[FILENAME]". Replace CODEBASE, CRC and FILENAME with the parameters in the config URI.
    Tip: Replace binaryType=2 to any other number to get the clients for different operating systems
    The launcher can be obtained through installing the application, on Windows the default installation path is C:\Program Files\Jagex\RuneScape Launcher\RuneScape.exe

    In the configuration, replace "codebase" with the root where your client will be downloaded from. Also, replace all "runescape.com" occurences with your own website/server. Otherwise NXT won't connect to your server!

    Patching the launcher and client
    The first thing we'll have to do is patch the game client and the launcher. The client has two RSA keys you want to patch: JS5 and login. Their purpose is the same as the Java client, so that should be easy enough.

    The launcher has three things we'll be patching:
    - The ConfigURI regex. This is a regex that determines if a link is valid for downloading the game's configurations. If you do not patch this you'll only be able to download RuneScape's game configurations from their site.
    - RSA keys. These RSA keys are used in the hash generation and confirming the hash. If the hash is not valid, the launcher will error and the client will not be downloaded.
    - The default ConfigURI. This allows you to double-click the launcher to open the game from your own webhost

    In order to patch the client and launcher we'll be using a Java application I wrote. The patcher also generates the hash and CRC of the client, as well as compressing the client to a LZMA format the launcher can read, which can then be uploaded to your website.

    Clone my Github repository that contains the patcher and run it. Create a folder named "library", put your client.exe and launcher.exe in there and modify "info.techsdev.nxt.Settings" and ensure your RSA keys match (Leave fields empty to have them automatically generated). Once that's done, run the patcher and wait for it to complete. Make sure you update the launcher keys in the settings file that the patcher generates for you. Otherwise you will need to re-download the launcher to download a new client (if you generate the hash with a different rsa key the hash will be invalid)

    The patcher will automatically patch and do a lot of things for you, including LZMA-compressing the client properly so that it can be downloaded by the launcher (Header in NXT LZMA is slightly different), generate the hash and CRC and patch the launcher's regex. Once all this is done, you're ready to move on to the next step.

    In your NXT game configuration replace the "download_crc_0" and "download_hash_0" with the values the patcher returned.

    Setting up your webhost
    This tutorial assumes you're using Apache, however, any webhost can be used. Refer to this Github gist for the files you should create on your Apache server. After this, paste the "compressed_client.exe" the patcher compressed for you in your codebase path and rename it to rs2client.exe (Where you put the files above and where you pointed the default URI to in the patcher). Don't forget to change your config.php with the config Jagex returned for your client. Ensure the PHP header is not removed when copy-pasting your own configuration - otherwise the launcher won't work.

    JS5
    New JS5 opcodes
    NXT uses a few extra opcodes. Java uses opcode 0 (low priority) and 1 (high priority). NXT adds three more opcodes: 32 (Low priority), 33 (High priority) and 17 (I assume this is high priority - that seems to work). The JS5 protocol itself remains untouched and should work fine with whatever works with Java.

    Checksum table
    Make sure your checksum table has the properly-encoded RSA block (65 bytes, a byte with value 10 followed by the whirlpool of the archive data). I think this is good in most sources, so don't worry too much about this one. Just keep it in your mind when you get errors.

    Launching the game
    Once everything's in place, double-click your "launcher_patched.exe" and you should be good to go! I hope this tutorial covered everything you need to get NXT to the login screen. If not, please leave a post below.

    NXT-related data
    Lastly there's a few pieces of important information involving NXT. This involves NPC updating and the map packet.

    Map packet
    The map packet, in NXT, has a few extra fields. So far I have identified one. The fields NXT uses do not seem to be obfuscated and are five shorts at the end of the regular map packet. I do not know anything about the dynamic map packet yet as my source does not support dynamic regions yet. I will create a new post or update this one once I have more information (or contribute yourself). The first of the five shorts is a reference to a new config NXT uses: WorldAreaType. Decoder here. I haven't figured anything about this config out yet. The WorldAreaType is located in cache index 2 (configs), file 83.

    For mainland you want to use area key 474 (Short). I have no clue what the other fields are for, but writing shorts MIN-MIN-MAX-MAX works just fine.

    Other than that NXT also has a bigger viewport and region size. For normal maps, you send RegionSize with id 0 (Size 104) to the Java client. In NXT you have to send the RegionSize with id 5 (Size 256). If you do not do this, the client will be stuck on a black screen.

    NPC updating - The following data works for my own source but I haven't been able to test it with Matrix yet, nor do I intend to rev Matrix to NXT. If someone would like to check this for me and report back, please do so!
    Since NXT has a bigger rendering distance, NPCs can also be sent from farther away. On RuneScape's servers Java uses 5 bits to write the NPC positions, whereas NXT uses 7. Of course you can stick with 5 even with NXT but then you wouldn't be using NXT to its full potential. This does require some changes in your NPC updating.

    The amount of bits that are read for NPC positions is sent by the server in the map packet, once again, 5 for Java and 7 for NXT.

    First of all, the distance check on Matrix is 14 for NPCs. The distance check should be calculated as followed:
    int range = ((1 << bits - 1) - 2);
    
    where bits is the viewport bits of the player (once again, 5 for Java, 7 for NXT)

    Now replace this piece of code on Matrix in LocalNPCUpdate
    
    				int x = n.getX() - player.getX();
    				int y = n.getY() - player.getY();
    
    with: Let me know if the snippet below is not clear enough
    
    		int check = ((1 << bits - 1) - 1);
    		int add = 1 << bits;
    
    		...
    
    				int x = n.getX() - player.getX();
    				int y = n.getY() - player.getY();
    				if(x < check) x += add;
    				if(y < check) y += add;
    
    		...
    				// Ensure these are in the correct order depending on your client!
    				stream.writeBits(bits, x);
    				stream.writeBits(bits, y);
    
    where bits is the viewport bits of the player (once again, 5 for Java, 7 for NXT)
    This will properly calculate the offsets of NPCs depending on the viewport bits of the client

    ISAAC
    Lastly ISAAC should be implemented in your server in order for NXT to work (Unless you manually patch this out of the client). ISAAC implementation can be tough and is something that this tutorial does not cover. The basic gist is you read the ISAAC keys from the login RSA block, that's your incoming ISAAC keys. Add 50 to each key and you have your outgoing ISAAC keys. For each packet you send and receive you use ISAAC to get the real opcode. I'm sure there's tutorials out there like on how to enable ISAAC if you really need one, but you'll have to implement it yourself, of course.
     
  2. Good guide,
    NXT has been hella fun learning, still so much to learn!
     
  3. Nice job with this - Keep it up!
     
Tags:
Loading...