[TypeScript/Nodejs] Open Source headless modular client

Posts 1–15 of 23 · Page 1 of 2
[TypeScript/Nodejs] Open Source headless modular client
In my spare time I've been developing a headless modular client in TypeScript. I've decided to release it here as it's pretty functional now and can be fun to play around with if you know a little bit of JavaScript/TypeScript.

This was mostly inspired by the C++ clientless made by @toddddd so thanks to him for making his code open source.

I don't really know C++ so I wanted to recreate it with Node, since it has great built in support for Net Sockets and Buffers, and since it is a fairly large project, TypeScript seemed like a better choice than just plain ES6 JavaScript.

This project isn't completed yet, quite a few of the packets are still missing implementations. All of the essential packets (like Ack packets) are implemented as well as other frequently used ones such as text and trade packets.
The GoundTile data is loaded from xml resources currently, but Objects.xml loading still needs to be added.

The project is modular, so it supports running plugins (similar to KRelay). The project only has one default plugin so far which is more of an example of how to structure plugins.

The account information is loaded through a JSON file, and it supports running multiple accounts at once. This is the structure of the accounts file:
 
acc-config.json
Code:
{
    "buildVersion": "X19.0.1",
    "accounts": [
        {
            "guid": "john@email.com",
            "password": "SecretPassWord11",
            "serverPref": "AsiaSouthEast"
        }
    ]
}


The client can be run anywhere from the console with a simple command and will connect to the nexus.
When it starts it will look something like this:


Side Note
I called this project nrelay (Nodejs Relay) before JRelay was released, I don't want there to be 3 different 'letter'-relay programs as that is a bit confusing. It's a lot of work to refactor the name everywhere but will probably happen at some point.
The name is also a tiny bit misleading as it's not actually a relay, but a client. All implemented packets do have a read/write implementation however, so it could be turned in to a relay with minimal extra code (the code could even be in a plugin).

If you get the client up and running, it won't do much other than sit in the nexus. The default plugin will respond to you if you whisper the client 'hello', so you can test if the client is working or not.



And here is an example of running more than one client. These bots will just walk in a circle along the edge of the nexus spawn platform.



The functionality of these bots walking in a circle around the nexus fountains was actually added by making a plugin. This is the source code for the plugin:
 
walkpath-plugin.ts
Code:
import { NrPlugin, HookPacket, Packet, PacketType, Client, Log } from './../core/plugin-module';

import { WorldPosData } from './../networking/data/world-pos-data';
import { NewTickPacket } from './../networking/packets/incoming/newtick-packet';

const path = [
    { x: 129.5824, y: 143.6437 }, // bottom-left
    { x: 138.5885, y: 143.6437 }, // bottom-right
    { x: 138.5885, y: 136.4980 }, // top-right
    { x: 129.5824, y: 136.4980 }  // top-left
];

 @NRPlugin({
    name: 'Path Walker',
    author: 'tcrane'
})
export default class WalkpathPlugin {

    private players: {
        [id: number]: any[]
    };

    constructor() {
        this.players = {};
    }

    @hookPacket(PacketType.NewTick)
    onNewTick(client: Client, newTickPacket: NewTickPacket): void {
        if (!this.players[client.playerData.objectId]) {
            this.players[client.playerData.objectId] = path.slice();
        }
        if (!client.nextPos) {
            const wp = new WorldPosData();
            const point = this.players[client.playerData.objectId].pop();
            this.players[client.playerData.objectId].unshift(point);
            wp.x = point.x;
            wp.y = point.y;
            client.nextPos = wp;
        }
    }
}


This project is hosted on my GitHub page where you will also find a readme on how to setup and run the client, as well as a large amount of documentation covering how to write plugins, packet types and data structures available to use when making plugins.

I thought GitHub links were not allowed, but have recently seen other posts using GitHub links. Just to be safe I won't link the GitHub but please let me know if the rules have changed @Raple @Ahl
The GitHub endpoint is '/thomas-crane/nrelay'.

The TypeScript source is attached to this post, but you will need to build the source yourself to run the client. You can look at the included readme file or the GitHub to see how to do this. The only thing you need to have installed before running this client is Nodejs

There is still a fair bit of functionality that can be added to the client, so feel free to open a pull request or an issue if you find a bug.

Virus Scans
Jotti. (0/17)
Virus Total. (0/51)

The packet ids have been updated to work with build X19.0.2

@Raple @Ahl please move this to the main post

Virus Scans
Jotti. (0/18)
VirusTotal. (0/59)
nrelay_mpgh.net.rar233 KB · 74 downloads Clean
nrelay_mpgh.net.rar235 KB · 34 downloads Clean
Very nice, looked at some of the classes looks clean and well documentated , I may try to use this for some bots in the foreseeable future.
Very interesting
Quote Originally Posted by Killer Be Killed View Post
In my spare time I've been developing a headless modular client in TypeScriptⓘ. I've decided to release it here as it's pretty functional now and can be fun to play around with if you know a little bit of JavaScript/TypeScript.

This was mostly inspired by the C++ clientless made by @toddddd so thanks to him for making his code open source.

I don't really know C++ so I wanted to recreate it with Node, since it has great built in support for Net Sockets and Buffers, and since it is a fairly large project, TypeScript seemed like a better choice than just plain ES6 JavaScript.

This project isn't completed yet, quite a few of the packets are still missing implementations. All of the essential packets (like Ack packets) are implemented as well as other frequently used ones such as text and trade packets.
The GoundTile data is loaded from xml resources currently, but Objects.xml loading still needs to be added.

The project is modular, so it supports running plugins (similar to KRelay). The project only has one default plugin so far which is more of an example of how to structure plugins.

The account information is loaded through a JSON file, and it supports running multiple accounts at once. This is the structure of the accounts file:
 
acc-config.json
Code:
{
    "buildVersion": "X19.0.1",
    "accounts": [
        {
            "guid": "john@email.com",
            "password": "SecretPassWord11",
            "serverPref": "AsiaSouthEast"
        }
    ]
}


The client can be run anywhere from the console with a simple command and will connect to the nexus.
When it starts it will look something like this:


Side Note
I called this project nrelay (Nodejs Relay) before JRelay was released, I don't want there to be 3 different 'letter'-relay programs as that is a bit confusing. It's a lot of work to refactor the name everywhere but will probably happen at some point.
The name is also a tiny bit misleading as it's not actually a relay, but a client. All implemented packets do have a read/write implementation however, so it could be turned in to a relay with minimal extra code (the code could even be in a plugin).

If you get the client up and running, it won't do much other than sit in the nexus. The default plugin will respond to you if you whisper the client 'hello', so you can test if the client is working or not.



And here is an example of running more than one client. These bots will just walk in a circle along the edge of the nexus spawn platform.



The functionality of these bots walking in a circle around the nexus fountains was actually added by making a plugin. This is the source code for the plugin:
 
walkpath-plugin.ts
Code:
import { NrPlugin, HookPacket, Packet, PacketType, Client, Log } from './../core/plugin-module';

import { WorldPosData } from './../networking/data/world-pos-data';
import { NewTickPacket } from './../networking/packets/incoming/newtick-packet';

const path = [
    { x: 129.5824, y: 143.6437 }, // bottom-left
    { x: 138.5885, y: 143.6437 }, // bottom-right
    { x: 138.5885, y: 136.4980 }, // top-right
    { x: 129.5824, y: 136.4980 }  // top-left
];

 @NRPlugin({
    name: 'Path Walker',
    author: 'tcrane'
})
export default class WalkpathPlugin {

    private players: {
        [id: number]: any[]
    };

    constructor() {
        this.players = {};
    }

    @hookPacket(PacketType.NewTick)
    onNewTick(client: Client, newTickPacket: NewTickPacket): void {
        if (!this.players[client.playerData.objectId]) {
            this.players[client.playerData.objectId] = path.slice();
        }
        if (!client.nextPos) {
            const wp = new WorldPosData();
            const point = this.players[client.playerData.objectId].pop();
            this.players[client.playerData.objectId].unshift(point);
            wp.x = point.x;
            wp.y = point.y;
            client.nextPos = wp;
        }
    }
}


This project is hosted on my GitHub page where you will also find a readme on how to setup and run the client, as well as a large amount of documentation covering how to write plugins, packet types and data structures available to use when making plugins.

I thought GitHub links were not allowed, but have recently seen other posts using GitHub links. Just to be safe I won't link the GitHub but please let me know if the rules have changed @Raple @Ahl
The GitHub endpoint is '/thomas-crane/nrelay'.

The TypeScript source is attached to this post, but you will need to build the source yourself to run the client. You can look at the included readme file or the GitHub to see how to do this. The only thing you need to have installed before running this client is Nodejsⓘ

There is still a fair bit of functionality that can be added to the client, so feel free to open a pull request or an issue if you find a bug.

Virus Scans
Jotti. (0/17)ⓘ
Virus Total. (0/51)ⓘ
is there away i can add you, on skype or dcord?
Quote Originally Posted by SeXZeFPS View Post
is there away i can add you, on skype or dcord?
Sure,
Killer Be Killed#1781
Approved.

Also, you're correct about GitHub links. I've removed them where possible
Hey this looks amazing! It's really well documented and intuitive, and it's such a godsend for people looking to get into rotmg hacking like myself. I sent you a request on dcord if you would be willing to answer a few questions.
Quote Originally Posted by nith822 View Post
Hey this looks amazing! It's really well documented and intuitive, and it's such a godsend for people looking to get into rotmg hacking like myself. I sent you a request on dcord if you would be willing to answer a few questions.
Yeah that's fine, although I'm not sure what timezone you're in so I might not be online at the same time.

X19.1.0 Update
Since the only thing that has changed is the packet ids, there is not point re-uploading the entire source code.
To update your packet ids, open the file src/networking/packet.ts, scroll to the bottom, and replace the existing PacketType enum with this:
Code:
export enum PacketType {
    Hello = 41,
    MapInfo = 67,
    Load = 97,
    Failure = 0,
    CreateSuccess = 21,
    Update = 5,
    UpdateAck = 62,
    AoeAck = 50,
    ShootAck = 79,
    Goto = 95,
    GotoAck = 19,
    Aoe = 88,
    NewTick = 68,
    Ping = 83,
    Pong = 80,
    Move = 84,
    Text = 26,
    PlayerText = 76,
    Create = 46,
    RequestTrade = 36,
    TradeRequested = 24,
    TradeStart = 17,
    ChangeTrade = 7,
    TradeChanged = 96,
    AcceptTrade = 91,
    CancelTrade = 100,
    TradeDone = 25,
    TradeAccepted = 6,
    ServerPlayerShoot = 90
}
EDIT:
You will need to rebuild the source after you change the packet ids.
The path plugin is not working
Quote Originally Posted by JiiJiiJari View Post
The path plugin is not working
The version on this post is extremely outdated and no longer working. Please get the latest version from the GitHub. The path plugin should work with the latest version from GitHub.
Quote Originally Posted by Killer Be Killed View Post
The version on this post is extremely outdated and no longer working. Please get the latest version from the GitHub. The path plugin should work with the latest version from GitHub.

The packets are outdated on the Pathwalker. I got help from KoolKash and its working fine now fixed code:


Code:
import { NrPlugin, HookPacket, Packet, PacketType, Client, Log } from './../core/plugin-module';

import { WorldPosData } from './../networking/data/world-pos-data';
import { NewTickPacket } from './../networking/packets/incoming/newtick-packet';

const path = [
    { x: 129.5824, y: 143.6437 }, // bottom-left
    { x: 138.5885, y: 143.6437 }, // bottom-right
    { x: 138.5885, y: 136.4980 }, // top-right
    { x: 129.5824, y: 136.4980 }  // top-left
];

  @//NrPlugin({
    name: 'Path Walker',
    author: 'tcrane'
})
export default class WalkpathPlugin {

    private players: {
        [id: number]: any[]
    };

    constructor() {
        this.players = {};
    }

    @//HookPacket(PacketType.NEWTICK)
    onNEWTICK(client: Client, newTickPacket: NewTickPacket): void {
        if (!this.players[client.playerData.objectId]) {
            this.players[client.playerData.objectId] = path.slice();
        }
        if (!client.nextPos) {
            const wp = new WorldPosData();
            const point = this.players[client.playerData.objectId].pop();
            this.players[client.playerData.objectId].unshift(point);
            wp.x = point.x;
            wp.y = point.y;
            client.nextPos = wp;
        }
    }
}
Take off the red // annoying tagging makes the code broken a bit.
The spots with a bit outdated code are marked green.
All thanks for the explanation how to fix it goes to Koolkash aka Rotmg Troller
Quote Originally Posted by Killer Be Killed View Post
The version on this post is extremely outdated and no longer working. Please get the latest version from the GitHub. The path plugin should work with the latest version from GitHub.
Is this still being updated and maintained? Looks very interesting, and I might be interested in forking to help it out.
Quote Originally Posted by Mew View Post
Is this still being updated and maintained? Looks very interesting, and I might be interested in forking to help it out.
Yes, the current version on GitHub is updated to X23.0.0 and it is still under active development. The next feature to be added is projectile handling, which is almost done.
Quote Originally Posted by Mew View Post
Is this still being updated and maintained? Looks very interesting, and I might be interested in forking to help it out.
Yeh, you wouldn't know it by looking at the number of posts in this thread but nrelay is polished as fuck.
Hey I was wondering if there is a cli command that I can call to force an update?
I was getting:
Code:
[00:31:35 | ResourceManager] Error reading Objects.json
Deleted Objects.json

Trying execution again with --debug as well.

Code:
sudo nrelay --debug
[00:32:18 | NRelay]           Starting in debug mode...
[00:32:18 | NRelay]           Checking for updates...
[00:32:19 | ResourceManager]  Error reading Objects.json
[00:32:19 | ResourceManager] Error: ENOENT: no such file or directory, open '/home/pantsu/projects/nrelay/resources/Objects.json'

I restored the original Objects.json and ran it with --debug.

Code:
[00:40:56 | ResourceManager]  Error reading Objects.json
[00:40:56 | ResourceManager] SyntaxError: Unexpected end of JSON input
Manually editing the Objects.json files and adding the following to the end of the file.
Code:
}
}
]
}
Made the launch Error disappear but I still can't get the test hello plugin to work either.
I still think my Objects.json might be lacking things, it's currently at 193458 lines long and I don't have a proper reference one saved that I can exchange it for or compared sizes to.
Posts 1–15 of 23 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us