Skip to content
Leonid Pospelov edited this page Aug 3, 2019 · 4 revisions

Extends User.

Event: 'raceMenuShow'

Emitted when Bot sees the character creation menu.

bot.on('raceMenuShow', async () => {
  bot.sendLook(new Look('Argonian', 'Female'));
});

Event: 'spawn'

Emitted when Bot sees self spawn.

  • pos - An array representing XYZ coordinates.
  • angleZ - An angle in degrees.
  • cellOrWorld - FormID of Cell or WorldSpace (0x0000003c for Tamriel).
bot.on('spawn', async (pos, angleZ, cellOrWorld) => {
  if (cellOrWorld === 0x0000003c) {
    console.log('spawned in Tamriel at', pos);
  }
});

Event: 'despawn'

Emitted when Bot sees self despawn (exiting to main menu).

bot.on('despawn', async () => {
  console.log('despawned');
});

Event: 'teleport'

Emitted when an attached actor is teleported via setPos.

  • pos - An array representing XYZ coordinates.
bot.on('teleport', async (pos) => {
  console.log('My new pos is', pos);
});

Event: 'rotate'

Emitted when an attached actor is rotated via setAngle.

  • angleZ - A number representing Z-Angle.
bot.on('rotate', async (angleZ) => {
  console.log('My new angle is', angleZ);
});

.getWorldState()

Dumps state of the world seen by Bot.

let state = await bot.getWorldState();
console.log(state);
/*
{
  localActorId: Number,
  actors: [{
    movement: Movement,
    look: Look | Null,
    lastAnimEvent: String,
    numMovementChanges: Number,
    numAnimEvents: Number
  }, ...]
}
*/

.sendLook(newLook)

Sends a new look. The server may ignore it if Bot is not in the character creation menu.

  • newLook - An instance of Look.
await bot.sendLook(new Look('Nord', 'Male'));

.sendMovement(newMovement)

Sends movement.

  • newMovement - An instance of Movement.
let pos = [x, y, z];
await bot.sendMovement(new Movement(pos));

.sendAnimEvent(animEvent)

await bot.sendAnimEvent('JumpStart');

Browser

Use bot.browser to access events and methods associated with the browser.

Event: 'customPacket'

Catches incoming custom packets (generated on the backend).

  • targetSystem - String. Should represent one of the systems in your gamemode.
  • data - Object with data from the gamemode.
bot.browser.on('customPacket', async (targetSystem, data) => {
  if (targetSystem === 'Echo') {
    bot.browser.sendCustomPacket('EchoResponse', data);
  }
})

.sendCustomPacket(targetSystem, data)

Simulates sending a custom packet from embedded browser.

  • targetSystem - String. Should represent one of the systems in your gamemode.
  • data - A serializable object with the information you want to be sent to the gamemode.
await bot.browser.sendCustomPacket('MyAwesomeSystem', { someData: '123' });