brutal.io
v1.0.0
Published
Brutal.io client!
Maintainers
Readme
Brutal.js
Brutal.io client created by dimden.
Currently only browser is supported (you can't run it in Node.js), feel free to contribute!
Support Discord Server: https://discord.gg/k4u7ddk.
Features
- Entire Client -> Server protocol (movement, clicks, nick, ....)
- Party support
- Leaderboard support
- Minimap support
- Getting player id
- Support of deaths and kills
TODO
- Implement Node.js support
- Implement entities support
- Fix bug with king
Example
// Using party (has player limit)
let bot = new Brutal({
party: "1wlc",
nick: `dimden's bot`,
autoplay: true
});
// Using raw server address
let bot = new Brutal({
address: "164.132.205.24:8080",
nick: `dimden's bot`,
autoplay: true
});Options
party- invite to the server (Note: this has ~70 user limit)nick- nick of the botautoplay- play again on deathcountry- your country code (defaultUA)address- raw address of server, no need forpartyoption
Events
server- found server address using party invite.{room, party, address}close- disconnected from server (will automatically reconnect).open- connected to server (it doesn't mean you're in game yet, usethis.playing)hello- sent "hello" message by protocolping- pinged serverid- got your id in gameking- updated king info (doesn't work yet)kill- killed someone{id, nick}died- died{id, nick}leaderboard- updated leaderboardrank- updated your rank on leaderboard{rank, score}map- got/updated map
API
this.party - your party invite if you have onethis.nick - your nickthis.address - address of server bot connected tothis.ws - WebSocketthis.room - your room id (only if you gave party link)this.ready - ready to join game (bool)this.id - your id in gamethis.playing - is in game (bool)this.rank - your rank in leaderboardthis.score - your scorethis.autoplay - autoplay on deaththis.leaderboard - leaderboard data, 10 length array, each player has id, score and nick.this.map - map datathis.country - options.country (default UA)this.init() - init everything
Opcodes
this.opcodes = {
client: {
OPCODE_PING: 0x00,
OPCODE_HELLO: 0x01,
OPCODE_HELLO_BOT: 0x02,
OPCODE_ENTER_GAME: 0x03,
OPCODE_LEAVE_GAME: 0x04,
OPCODE_INPUT: 0x05,
OPCODE_INPUT_BRAKE: 0x06,
OPCODE_AREA_UPDATE: 0x07,
OPCODE_CLICK: 0x08
},
server: {
OPCODE_PONG: 0x00,
OPCODE_MAP_CONFIG: 0xA0,
OPCODE_ENTERED_GAME: 0xA1,
OPCODE_ENTITY_INFO_V1: 0xB4,
OPCODE_ENTITY_INFO_V2: 0xB3,
OPCODE_EVENTS: 0xA4,
OPCODE_LEADERBOARD_V1: 0xA5,
OPCODE_LEADERBOARD_V2: 0xB5,
OPCODE_MINIMAP: 0xA6
},
event: {
EVENT_DID_KILL: 0x01,
EVENT_WAS_KILLED: 0x02
},
entity: {
ENTITY_ITEM: 4,
ENTITY_PLAYER: 5,
ENTITY_COLLIDER: 1
},
sub_entity: {
SUB_ENTITY_ITEM_ATOM: 0,
SUB_ENTITY_ITEM_ENERGY: 1,
SUB_ENTITY_ITEM_TRI_PLUS: 2,
SUB_ENTITY_ITEM_TRI_MINUS: 3,
SUB_ENTITY_ITEM_REDFLAIL: 4
}
}Net
this.net.findServer(party)- get server address by party link (party link is optional if you just want to find random server), returns{address, room, party}this.net.onClose()- on websocket closethis.net.onOpen()- on websocket openthis.net.onMessage(msg)- on websocket messagethis.net.sendHello(width, height)- send hello message (width and height are optional)this.net.ping()- ping serverthis.net.sendNick(nick)-nickis optinal; in brutal.io this method starts the game, bewarethis.net.sendInput(angle, throttle)- send movementthis.net.sendClick(hold)- send click
World
this.world.king-{id, x, y}(doesn't work yet)this.world.connect()- connect to serverthis.world.entities- object with entities (doesn't work yet)this.world.updateMapInfo(view)- update mapthis.world.processLeaderboard(view, op)- process leaderboard datathis.world.processEvents(view)- process event datathis.world.updateEntities(view, op)- process entity data (doesn't work yet)
Utils
this.utils.getString(view, offset)- get string from dataviewthis.utils.getPlayerName(playername)- get proper nick
Warning
There's a lot of stuff, but you actually don't need anything from this.world, this.utils, you only need movement and click methods,
leaderboard, id, rank, minimap, death & kills. Client connects to server and joins the server automatically, and if there's autoplay option, it'll play again on death!
Other
Contributions are very appreciated!
Created by dimden. Discord.
