RLBot JavaScript Documentation
Table of Contents generated with Doctoc
- Links
- Bot Making
- API Reference
- BaseAgent(name, team, index)
- GameState
- new GameState(ballState: BallState, carState: Array, boostState: Array, gameInfoState: GameInfoState)
- new GameInfoState(worldGravityZ: Number, gameSpeed: Number)
- new BoostState(respawnTime: Number)
- new CarState(physics: Physics, boostAmount: Number, jumped: Boolean, doubleJumped: Boolean)
- new BallState(physics: Physics)
- new Physics(location: Vector3, rotation: Rotator, velocity: Vector3, angularVelocity: Vector3)
- new Rotator(pitch: Number, yaw: Number, roll, Number)
- new Vector3(x: Number, y: Number, z: Number)
- Game data objects
- Setting up a development environment
Links
Bot Making
Starting a JavaScript Bot
The first thing you'll want to do is start a class that extends the rlbot.BaseAgent
class. This allows you to easily accomplish things that are harder without extending the BaseAgent
, like sending quick chats. You'll also need to make a new Manager
that has a parameter of the class extending BaseAgent
.
Example:
const BaseAgent SimpleController Manager = ; { supername team index; // pushes these all to `this`. console; // Print our name to the console, e.g. "MyBot" } { return ; // Do nothing in-game } const manager = MyBot; // This makes a managermanagerstart; // This starts the manager
API Reference
BaseAgent(name, team, index)
You shouldn't be calling new BaseAgent
, instead you should extend it! See the example
.getOutput(gameTickPacket, ballPrediction) -> SimpleController
Once again you shouldn't be calling this function, you should be implementing this function!
-
gameTickPacket: The object containing all the current field data, see gameTickPacket
-
ballPrediction: The object containing all the future positions of the ball, calculated using Chip's notes, see ballPrediction for the structure
-
Return a SimpleController
.sendQuickChat(quickChatSelection, teamOnly)
- quickChatSelection: See quickChats
- teamOnly: A boolean, determines if the quickChat should be visible to the team only or not
Example:
//top of the fileconst quickChats = //inside your bot classthis
.setGameState(GameState)
This allows to set the state of the game
- GameState: a new GameState, see GameState for refrence
Example:
let physics = null null null null gameTickPacketballphysicsvelocityz+650/60 //assumes you are running 60fpslet ball = physics this
GameState
BallState, carState: Array<CarState>, boostState: Array<BoostState>, gameInfoState: GameInfoState)
new GameState(ballState:new GameInfoState(worldGravityZ: Number, gameSpeed: Number)
new BoostState(respawnTime: Number)
Physics, boostAmount: Number, jumped: Boolean, doubleJumped: Boolean)
new CarState(physics:Physics)
new BallState(physics:Vector3, rotation: Rotator, velocity: Vector3, angularVelocity: Vector3)
new Physics(location:new Rotator(pitch: Number, yaw: Number, roll, Number)
new Vector3(x: Number, y: Number, z: Number)
Game data objects
SimpleController
{
throttle:float; /// -1 for full reverse, 1 for full forward
steer:float; /// -1 for full left, 1 for full right
pitch:float; /// -1 for nose down, 1 for nose up
yaw:float; /// -1 for full left, 1 for full right
roll:float; /// -1 for roll left, 1 for roll right
jump:bool; /// true if you want to press the jump button
boost:bool; /// true if you want to press the boost button
handbrake:bool; /// true if you want to press the handbrake button
useItem:bool; /// true if you want to use a rumble item
}
throttle
: Default is0
. To go forward, change this to1
. To go backwards, change this to-1
. Setting this to0
will stop the throttle. NOTE: Setting this to0
does not slow the car down very well. If you want to brake, change the throttle to the opposite from what it was. E.g. when this is set to1
, set this to-1
until the bot has slowed down.steer
: Default is0
. To steer right, change this to1
. To steer left, change this to-1
. Setting this to0
will steer forwards.pitch
: Default is0
. To tip the bot forwards, change this to-1
. To tip the bot backwards, change this to1
. NOTE: Changing this is a way to dodge.roll
: Default is0
. To roll clockwise(relative to the back of the car), change this to-1
. To roll anti-clockwise(relative to the back of the car), change this to1
. NOTE: Changing this is a way to dodge.yaw
: Default is0
. To rotate the bot clockwise(relative to the top of the car), change this to-1
. To rotate the bot clockwise(relative to the top of the car), change this to1
. NOTE: Changing this is a way to dodge.boost
: Default isfalse
. To use boost, change this totrue
. To not use boost, change this tofalse
.jump
: Default isfalse
. To jump, change this totrue
. To not jump, change this tofalse
handbrake
: Default isfalse
. To powerslide, change this totrue
. To not powerslide, change this tofalse
.useItem
: Default isfalse
. To use a rumble item, change this totrue
. To not use a rumble item, change this tofalse
.
gameTickPacket
"players": "physics": "location": "x": -256 "y": -3840 "z": 17010000228881836 "rotation": "pitch": -0009587380103766918 "yaw": 15707963705062866 "roll": 0 "velocity": "x": 0 "y": 0010999999940395355 "z": 0210999995470047 "angularVelocity": "x": -00006099999882280827 "y": 0 "z": 0 "scoreInfo": "score": 0 "goals": 0 "ownGoals": 0 "assists": 0 "saves": 0 "shots": 0 "demolitions": 0 "isDemolished": false "hasWheelContact": true "isSupersonic": false "isBot": true "jumped": false "doubleJumped": false "name": "Bot" "boost": 34 "team": 0 ... // Order based on index "boostPadStates": "isActive": true "timer": 0 "isActive": true "timer": 0 ... // Order can be found at the useful game values "ball": "physics": "location": "x": -8636399536132812 "y": 2814499816894531 "z": 9313999938964844 "rotation": "pitch": 018158496916294098 "yaw": 004918326064944267 "roll": 006778277456760406 "velocity": "x": -5672109375 "y": 17926100158691406 "z": 0 "angularVelocity": "x": -1809209942817688 "y": -5720609664916992 "z": 0011809999123215675 "latestTouch": "playerName": "SuperVK" "gameSeconds": 4053416748046875 "location": "x": -1933159637451172 "y": 6418572998046875 "z": 9249647521972656 "normal": "x": -09340062141418457 "y": 035719090700149536 "z": 0006852129008620977 "team": 1 "playerIndex": 2 "dropShotInfo": "absorbedForce": 0 "damageIndex": 0 "forceAccumRecent": 0 "gameInfo": "secondsElapsed": 4062083435058594 "gameTimeRemaining": -39608331298828125 "isOvertime": false "isRoundActive": true "isKickoffPause": false "isMatchEnded": false "worldGravityZ": -650 "gameSpeed": 0 "tileInformation": //for Dropshot "teams": "teamIndex": 0 "score": 0 "teamIndex": 1 "score": 0
ballPrediction
"slices": "gameSeconds": 4062083435058594 "physics": "location": "x": -8636399536132812 "y": 2814499816894531 "z": 9313999938964844 "rotation": null // Ball prediction doesn't have rotation "velocity": "x": -5672109375 "y": 17926100158691406 "z": 0 "angularVelocity": "x": -1809209942817688 "y": -5720609664916992 "z": 0011809999123215675 ... // One slice represents one frame
quickChats
information
IGotIt
:0
- I got it!NeedBoost
:1
- Need boost!TakeTheShot
:2
- Take the shot!Defending
:3
- Defending!GoForIt
:4
- Gor for it!Centering
:5
- Centering!AllYours
:6
- All yours!InPosition
:7
- In position!Incoming
:8
- Incoming!NiceShot
:9
- Nice shot!GreatPass
:10
- Great pass!Thanks
:11
- Thanks!WhatASave
:12
- What a save!NiceOne
:13
- Nice one!WhatAPlay
:14
- What a play!GreatClear
:15
- Great clear!NiceBlock
:16
- Nice block!
compliments
NiceShot
:9
- Nice shot!GreatPass
:10
- Great pass!Thanks
:11
- Thanks!WhatASave
:12
- What a save!NiceOne
:13
- Nice one!WhatAPlay
:14
- What a play!GreatClear
:15
- Great clear!NiceBlock
:16
- Nice block!
reactions
OMG
:17
- OMG!Noooo
:18
- Noooo!Wow
:19
- Wow!CloseOne
:20
- Close one.NoWay
:21
- No way!HolyCow
:22
- Holy cow!Whew
:23
- Whew.Siiiick
:24
- Siiiick.Calculated
:25
- Calculated.Savage
:26
- Savage!Okay
:27
- Okay.
apologies
Cursing
:28
- $#@%!NoProblem
:29
- No problem!Whoops
:30
- Whoops.Sorry
:31
- Sorry!MyBad
:32
- My bad.Oops
:33
- Oops.MyFault
:34
- My fault.
postGame
Gg
:35
- GGWellPlayed
:36
- Well played.ThatWasFun
:37
- That was fun!Rematch
:38
- Rematch!OneMoreGame
:39
- One more game!WhatAGame
:40
- What a game!NiceMoves
:41
- Nice moves!EverybodyDance
:42
- Everybody dance!
custom
Toxic_WasteCPU
:44
- Waste of CPU cyclesToxic_GitGut
:45
- Git gud*Toxic_DeAlloc
:46
- De-Allocate YourselfToxic_404NoSkill
:47
- 404: Your skill not foundToxic_CatchVirus
:48
- Get a virusUseful_Passing
:49
- Passing!Useful_Faking
:50
- Faking!Useful_Demoing
:51
- Demoing!Useful_Bumping
:52
- BOOPINGCompliments_TinyChances
:53
- The chances of that was 47525 to 1*Compliments_SkillLevel
:54
- Who upped your skill level?Compliments_proud
:55
- Your programmer should be proudCompliments_GC
:56
- You're the GC of BotsCompliments_Pro
:57
- Are you Bot? *
Setting up a development environment
You'll need:
-
Node.js
-
Python 3.7
-
windows-build-tools, which you can get with node.js by running
$ npm install -g windows-build-tools
in an administrator terminal. This is used to build some dependencies that are in C or C++.
-
Fork this repo (if you aren't a collaborator)
-
Clone your fork or SuperVK/RLBotJS with:
$ git clone https://github.com/[username/SuperVK]/RLBotJS.git
-
Clone the example bot with:
$ git clone https://github.com/SuperVK/RLBotJavascriptExample.git
-
Go into RLBotJS:
$ cd ./RLBotJS
-
Install deps:
$ npm install
-
Make changes
-
Link it globally:
$ npm link
or skip this step -
Go into the example:
$ cd ../RLBotJavascriptExample
-
Link it with the changes you made:
$ npm link rlbot-test
. If you skipped step 7 run$ npm install ../RLBotJS
instead -
Test your changes with
run.bat
in the rlbot folder of the example bot or the new GUI -
You're all done! Now, you might want commit your changes (in the RLBotJS directory) and push those changes (in the RLBotJS directory), and then make a pull request.